package com.tarena.lbs.business.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 *这个配置类专门声明业务所需组件用的
 *声明一个路由交换机 Direct  direct_demo_ex
 *声明一个普通队列 Queue demo_queue
 *确定绑定关系 demo_rk做路由key值绑定
 */

@Configuration
@Slf4j
public class DeclareConfiguration {

    @Bean
    public Exchange delayExchange(){
        return new FanoutExchange("store_location_exchange");
    }

    @Bean
    public Queue delayQueue(){
        return QueueBuilder.nonDurable("store_delay_queue")
                .build();
    }

    @Bean
    public Binding delayBinding(){
        return BindingBuilder
                .bind(delayQueue())
                .to(delayExchange())
                .with("").noargs();
    }
}
